//console.log("abc".split(""));
/**
 * 大数加法js代码，后面要用
 * @param x
 * @param y
 * @returns {string}
 */
function add(x, y) {
    while (x.length < y.length) x = "0" + x;
    while (y.length < x.length) y = "0" + y;

    let a = x.split('').reverse().map(t => parseInt(t));
    let b = y.split('').reverse().map(t => parseInt(t));
    let c = new Array(a.length);
    c.fill(0);
    let carry = 0;
    for (let i = 0; i < a.length; i++) {
        c[i] = a[i] + b[i] + carry;
        carry = c[i] > 9 ? 1 : 0;
        if (carry > 0) {
            c[i] -= 10;
        }
    }
    if (carry > 0) {
        c.push(1);
    }
    return c.reverse().map(x => "" + x).join("");

}

function largeSum(arr) {

    return parseInt(arr.reduce((x, y) => add(x, y)).substr(0, 10));
}

// Only change code above this line

const testNums = [
    '37107287533902102798797998220837590246510135740250',
    '46376937677490009712648124896970078050417018260538'
];

console.log(largeSum(testNums));